Total Complexity | 2 |
Total Lines | 13 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | /* eslint-disable no-magic-numbers */ |
||
10 | export default class RandomGenerator extends Generator { |
||
11 | generate() { |
||
12 | const bytes = crypto.randomBytes(7); |
||
13 | |||
14 | let randomValue = (bytes[0] % (2 ** 5)) / (2 ** 5); |
||
15 | |||
16 | bytes.slice(1).forEach(byte => { |
||
17 | randomValue = (randomValue + byte) / (2 ** 8); |
||
18 | }); |
||
19 | |||
20 | return randomValue; |
||
21 | } |
||
22 | } |
||
23 |